package com.unismc.charge.collector.controller;

import com.unismc.charge.collector.cache.ChargeInfoCache;
import com.unismc.charge.collector.service.QueryService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.time.LocalDateTime;

/**
 * @author: Forward Seen
 * @description:
 * @createTime: 2024/4/29 16:25
 * @since: 1.0
 */
@Slf4j
@RestController
@RequestMapping("testQuery")
public class TestQueryStationController {
    @Resource
    private QueryService queryService;

    @GetMapping("stationsInfo")
    public void queryStationsInfo() {
        log.info("queryStationsInfo 测试查询充电桩信息 查询时间：{}", LocalDateTime.now());
        queryService.queryStationsInfo();
    }


    @GetMapping("stationsStatus")
    public void queryStationsStatus() {
        log.info("queryStationsStatus 测试查询设备接口状态 查询时间：{}", LocalDateTime.now());
        queryService.queryStationsStatus();
    }

    /**
     * 每天0:00查询前一天的统计信息
     */
    @GetMapping("stationStats")
    public void queryStationStats() {
        log.info("queryStationStats 测试查询统计信息 查询时间：{}", LocalDateTime.now());
        queryService.queryStationsStats();
    }

    @GetMapping("clearCache")
    public void clearCache(){
        ChargeInfoCache.stationInfoCache.clear();
        ChargeInfoCache.stationIdCache.clear();
        ChargeInfoCache.equipmentInfoCache.clear();
        ChargeInfoCache.connectorInfoCache.clear();
    }
}
